<template>
<!-- 作品详情 -->
  <div class="home">
    <menuBar></menuBar>
    <div class="personalCenter">
        <headPortrait ref="headPortraitRef" class="headPortrait"></headPortrait>
        <div class="page">
            <div class="content">

                  <div class="title">
                      <p>{{state.detailObj.title}}</p>
                      <div class="right">
                          <span>浏览{{state.detailObj.video_num}}次</span>
                          <span>分享{{state.detailObj.forward_num}}次</span>
                      </div>
                  </div>

                  <div class="desc" v-if="state.type!=2">
                        {{state.detailObj.synopsis}}
                  </div>

                   <div class="detail" v-if="state.type!=2" v-html="state.detailObj.details">
                   </div>

                  <div class="video" v-if="state.type==2">
                    <video width="800" height="400"  controls="controls" :src="state.detailObj.video_url">

                    </video>
                  </div>


                  <div class="writerInfo">
                      <div class="author">
                          <div class="cover">
                              <img :src="state.writer.avatar" alt="">
                          </div>
                          <div class="info">
                              <div class="name">{{state.writer.nickname}}</div>
                              <div class="time">{{state.detailObj.ctime}}</div>
                          </div>
                      </div>
                      <div class="keyword">
                          关键字：
                          <span></span>
                      </div>
                  </div>

                  <div class="comment">
                      <div class="commentArr">
                          <div class="count">评论{{state.commentTotal}}条</div>
                          <div class="arrItem" v-for="(item,index) in state.commentArr" :key="index">
                             <div class="cover">
                               <img :src="item.headimg" />
                             </div>
                             <div class="info">
                                <div class="name">{{item.username}}</div>
                                <div class="text">{{item.content}}</div>
                                <span class="time">{{item.ctime}}</span>
                             </div>
                             <div class="btn">
                                回复
                             </div>

                          </div>
                      </div>
                  </div>


            </div>
        </div>
    </div>
  </div>
</template>
<script>
import { getCurrentInstance, onMounted, reactive,inject,onActivated } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
import menuBar from './component/menuBar'
import headPortrait from './component/headPortrait'
import uploadFile from '@/components/uploadFile/uploadFile'
const state = reactive({
    detailObj:{},
    commentArr:[],
    writer:{},
    commentTotal:'',
    type:'',
  });
export default {
  name: 'productionDetail',
  components: {
    menuBar,
    headPortrait,

  },
  setup(props,{emit}) {
      const ctx = getCurrentInstance();
      const _this = ctx.appContext.config.globalProperties
      const router = useRouter();
      const store = useStore();
      const echarts = inject("ec");//引入
      function getDetail(){
        let data = router.currentRoute._value.query
        state.type = data.type
        _this.$request({
          url:'/api/pcWriter/information_row',
          data:{
            inf_id: data.inf_id,
            type: data.type,
          }
        }).then(res=>{
          console.log(res);
          if (res.code==1) {
            state.detailObj = res.data
            state.writer = res.data.writer
          }else{
            _this.$message.error('暂时数据')
          }
        })
      }
      function getComment(){
        let data = router.currentRoute._value.query
        _this.$request({
          url:'/api/pcWriter/inf_comment',
          data:{
            inf_id: data.inf_id,
            page : '1',
            pagesize : '10',
          }
        }).then(res=>{
          console.log(res);
          if (res.code==1) {
            state.commentArr = res.data.data
            state.commentTotal = res.data.total
          }else{
            _this.$message.error('暂时数据')
          }
        })
      }
     onMounted(()=>{
        getDetail();
        getComment();
      });
      onActivated(()=>{
        // state.headEdit=false
      })
      return{
        state
      }
  },
  data () {
    return {
    }
  },
  props: {},
  watch: {},
  methods: {},
  computed: {},
  mounted () {
  },
}
</script>
<style lang="scss" scoped>
  /deep/  .el-input.is-disabled .el-input__inner{
    cursor: auto;
    color: #606266;
    background-color: #fff;
    border: 1px solid transparent;
    box-sizing: border-box;
  }
  @media screen and (max-width: 1000px) {
       .home{
         .personalCenter{
           width: 100% !important;
           .content{
             width: 90% !important;
           }
         }
       }

  }
  @media screen and (max-width: 1300px) {
       .home{
         .personalCenter{
           width: 100% !important;
           .content{
             width: 90% !important;
           }
         }
       }

  }

    .home{
      display: flex;
      // height: 100vh;
      width: 100%;
      .personalCenter{
        width: calc( 100% - 255px );
        position: relative;
        overflow: hidden;
       .page{
          position: absolute;
          top: 90px;
          height: 90vh;
          width: 100%;
          background-color: #fff;
          overflow-y: auto;
          display: flex;
          justify-content: center;
         .content{
            background-color: #fff;
            width: 60%;
            height: 100%;

              .title {
                display: flex;
                justify-content: space-between;
                align-items: center;
                  p {
                    color: #17181A;
                    font-size: 28px;
                  }
                  .right {
                    span {
                      margin-right: 20px;
                      color: #8A9099;
                    }
                  }
              }

                .desc {
                  background-color: #EAF0F9;
                  color: #8A9099;
                  height: 69px;
                  display: grid;
                  place-items: center;
                  width: 100%;
                }

                .detail {
                  margin: 30px 0 40px;
                }

            .video{
              display: flex;
              justify-content: center;
              margin: 30px 0;
              box-shadow: 1px 1px 3px rgba(0,0,0,.1),0px 1px 3px rgba(0,0,0,.1) inset;
              background-color: #fff;
            }

            .writerInfo {
                    .author {
                      display: flex;
                      .cover {
                        width: 70px;
                        height: 70px;
                        img {
                          width: 100%;
                          border-radius: 50%;
                        }
                      }

                      .info {
                        display: flex;
                        flex-direction: column;
                        justify-content: space-evenly;
                        margin-left: 20px;
                        .name {
                          font-size: 20px;
                        }

                        .time {
                          color: #939599;
                        }
                      }
                    }

                    .keyword {
                      margin-top: 20px;
                      color: #45484D;
                      font-weight: 18px;
                      span {

                      }
                    }
              }

            .comment {
              width: 100%;
              padding: 30px 0 50px;
                .commentArr {
                  box-shadow: 1px 1px 3px rgba(0,0,0,.1),0px 1px 3px rgba(0,0,0,.1) inset;
                  background-color: #fff;
                  padding: 30px 0;
                  .count {
                    font-size: 18px;
                    color: #45484D;
                    margin-left: 25px;
                  }

                  .arrItem:last-child{
                      border-bottom: 0;
                      margin-bottom: 0;
                  }

                  .arrItem {
                    margin: 20px 30px;
                    border-bottom: 1px solid #F0F0F0;
                    padding-bottom: 20px;
                    display: flex;
                    height: 105px;
                    // align-items: center;
                    .cover{
                      img{
                        width: 70px;
                        height: 70px;
                        border-radius: 50%;
                      }
                    }
                    .info{
                      flex: 1;
                      margin-left: 30px;
                      padding-top: 5px;
                      display: flex;
                      flex-direction: column;
                      .name{
                        color: #45484D;
                        font-size: 18px;
                        margin-bottom: 5px;
                      }
                      .text{
                        flex: 1;
                        color: #505966;
                        font-size: 16px;
                      }
                      .time{
                        color: #939599;
                      }
                    }
                    .btn{
                      color: #939599;
                      display: flex;
                      align-items: flex-end;
                    }

                  }
                }
            }




          }
        }
      }
    }
</style>
